package com.atguigu.gmall.item.util;

import com.atguigu.gmall.model.user.UserInfo;

/**
 * @author 搭忆长安
 * @version 1.0
 * @date 2021年07月09日 20:10
 * @ClassName:UserThreadLocalUtils
 * @Description: TODO
 */
public class UserThreadLocalUtils {
    private  final  static  ThreadLocal<UserInfo> userThreadLocal = new ThreadLocal<>();

    /**
     * 设置当前线程中的用户
     * @param user
     */
    public static  void setUser(UserInfo user){
        userThreadLocal.set(user);
    }

    /**
     * 获取线程中的用户
     * @return
     */
    public static  UserInfo getUser(){
        return  userThreadLocal.get();
    }
}
